#ifndef TFCALC_H
#define TFCALC_H
#include <docstruct.h>
#include <QHash>
#include <QVector>
#include <QList>
#include <QCryptographicHash>

typedef QList<float> vect;

class tfcalc
{

public:
    tfcalc();
    tfcalc(QList<DocStruct> dStruct);

public:
    unsigned int getDocCount();
    unsigned int getTermCount();
    void addDoc(QList<DocStruct> dStruct);
    QHash< QString, QList<float> > calculateTFIDF(QHash<QString,vect> mtd);
    float calculateManh(unsigned int i1, unsigned int i2,QHash<QString, vect> mtd);
    float calculateEucl(unsigned int i1, unsigned int i2,QHash<QString, vect> mtd);
    float calculateCheb(unsigned int i1, unsigned int i2,QHash<QString, vect> mtd);
    int calculateLeven(QStringList str1, QStringList str2);
    QList<vect> calculateLeven(QList<DocStruct> dStruct);
    QList<vect> calculateShingle(QList<DocStruct> dStruct, int shLength, int hashLength);
    QList<vect> calculateJaccard();
    QList<vect> calculateDist(QHash<QString,vect> mtd,QString type);
    QList<vect> getDist(QString dist, QString weight);
    QList<vect> getDist(QString type);
    void clear();


    QHash<QString, QList<float> > tf;
    QHash<QString, float> idf;
    float distmax;




private:
    unsigned int doc_size;
    unsigned int term_size;

    QString md5Hash(QString str)
    {
        QCryptographicHash md5(QCryptographicHash::Md5);
        md5.addData(str.toAscii());
        return md5.result().toHex().constData();
    }

    int Min( const int x, const int y )
    {
       return ( x > y ) ? y : x;
    }


};

#endif // TFCALC_H
